package it.ilgrv.demiurgo.persistence.tables.character;

import it.ilgrv.demiurgo.persistence.CharacterSubscription;
import it.ilgrv.demiurgo.persistence.tables.faction.Member;
import it.ilgrv.demiurgo.persistence.tables.inscription.Partecipant;
import it.ilgrv.demiurgo.persistence.tables.inscription.User;
import it.ilgrv.demiurgo.persistence.tables.skill.LearnedSkill;
import it.ilgrv.demiurgo.persistence.tables.skill.Teacher;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the character database table.
 * 
 */
@Entity
public class Character extends it.ilgrv.demiurgo.persistence.GenericTable implements Serializable {
	private static final long			serialVersionUID	= 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int							id;

	private int							availableXP;

	@Temporal(TemporalType.DATE)
	private Date						creationDate;

	private String						name;

	private boolean						npc;

	private String						surname;

	private int							totalXP;

	private int							version;

	// bi-directional many-to-one association to Teacher
	@ManyToOne
	private Teacher						teacher;

	@ManyToOne
	@JoinColumn(name = "user_id")
	private User						user;

	@OneToOne
	@JoinColumn(name = "characterStatus_id")
	private CharacterStatusType			currentCharacterStatus;

	// bi-directional many-to-one association to CharacterStatusLog
	@OneToMany(mappedBy = "character")
	private Set<CharacterStatusLog>		characterStatusLogs;

	// bi-directional many-to-one association to CharacterSubscription
	@OneToMany(mappedBy = "character")
	private Set<CharacterSubscription>	characterSubscriptions;

	// bi-directional many-to-one association to LearnedSkill
	@OneToMany(mappedBy = "character")
	private Set<LearnedSkill>			learnedSkills;

	// bi-directional many-to-one association to Member
	@OneToMany(mappedBy = "character")
	private Set<Member>					members;

	// bi-directional many-to-one association to PxLog
	@OneToMany(mappedBy = "character")
	private Set<PxLog>					pxLogs;

	@OneToMany(mappedBy = "character")
	private Set<Partecipant>			partecipants;

	public Character() {
	}

	public Character(
			String name,
			String surname,
			boolean npc) {
		this.name = name;
		this.surname = surname;
		this.npc = npc;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getAvailableXP() {
		return this.availableXP;
	}

	public void setAvailableXP(int availableXP) {
		this.availableXP = availableXP;
	}

	public CharacterStatusType getCurrentCharacterStatus() {
		return this.currentCharacterStatus;
	}

	public void setCurrentCharacterStatus(CharacterStatusType currentCharacterStatus) {
		this.currentCharacterStatus = currentCharacterStatus;
	}

	public Date getCreationDate() {
		return this.creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean getNpc() {
		return this.npc;
	}

	public void setNpc(boolean npc) {
		this.npc = npc;
	}

	public String getSurname() {
		return this.surname;
	}

	public void setSurname(String surname) {
		this.surname = surname;
	}

	public int getTotalXP() {
		return this.totalXP;
	}

	public void setTotalXP(int totalXP) {
		this.totalXP = totalXP;
	}

	public int getVersion() {
		return this.version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Teacher getTeacher() {
		return this.teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	public Set<CharacterStatusLog> getCharacterStatusLogs() {
		return this.characterStatusLogs;
	}

	public void setCharacterStatusLogs(Set<CharacterStatusLog> characterStatusLogs) {
		this.characterStatusLogs = characterStatusLogs;
	}

	public Set<CharacterSubscription> getCharacterSubscriptions() {
		return this.characterSubscriptions;
	}

	public void setCharacterSubscriptions(Set<CharacterSubscription> characterSubscriptions) {
		this.characterSubscriptions = characterSubscriptions;
	}

	public Set<LearnedSkill> getLearnedSkills() {
		return this.learnedSkills;
	}

	public void setLearnedSkills(Set<LearnedSkill> learnedSkills) {
		this.learnedSkills = learnedSkills;
	}

	public Set<Member> getMembers() {
		return this.members;
	}

	public void setMembers(Set<Member> members) {
		this.members = members;
	}

	public Set<PxLog> getPxLogs() {
		return this.pxLogs;
	}

	public void setPxLogs(Set<PxLog> pxLogs) {
		this.pxLogs = pxLogs;
	}

	public void addPxLogs(PxLog pxLog) {
		if (this.pxLogs == null) {
			pxLogs = new HashSet<PxLog>();
		}
		pxLogs.add(pxLog);
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Set<Partecipant> getPartecipants() {
		return partecipants;
	}

	public void setPartecipants(Set<Partecipant> partecipants) {
		this.partecipants = partecipants;
	}

	public void addPartecipants(Partecipant patecipant) {
		if (this.partecipants == null) {
			this.partecipants = new HashSet<Partecipant>();
		}
		this.partecipants.add(patecipant);
	}
}